import React from "react";
import {Drawer} from "antd";
import {useFileViewStore} from "@/pages/HomePage/FileDive/FileDiveStore.ts";
import Empty from "antd/es/empty/empty";
import Content from "@/pages/HomePage/FileDive/FileDiveView/FilePreviewDrawer/Content.tsx";

/**
 * 文件预览抽屉
 */
const App: React.FC = () => {
    const previewFile = useFileViewStore(state => state.previewFile)
    const previewDrawerOpen = useFileViewStore(state => state.previewDrawerOpen)
    const setPreviewDrawerOpen = useFileViewStore(state => state.setPreviewDrawerOpen)

    return (
        <Drawer
            open={previewDrawerOpen}
            onClose={() => {
                setPreviewDrawerOpen(false)
            }}
            styles={{
                body: {
                    padding: "0",
                },
            }}
            destroyOnClose
        >
            {
                previewFile ?
                    <Content previewFile={previewFile}/> :
                    <Empty/>
            }
        </Drawer>
    )
}

export default App
